package Food_controller;

import jakarta.servlet.http.HttpServlet;

import java.io.IOException;

import Food_dao.UserDao;
import Food_model.Food;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;


@WebServlet("/delete")
public class DeleteController extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			req.setCharacterEncoding("utf-8");
			String foodid=req.getParameter("foodid");
			Food fd=new Food();
			fd.setFoodid(foodid);
			//调用对象删除方法进行删除操作
			fd.deleteFoodById();
			req.getRequestDispatcher("right.jsp").forward(req, resp);
			
	}

}

